Skip to content

Navigation components and testing utilities - #84

Merged
meszmate merged 8 commits into
mainfrom
feature/navigation-and-testing-utilities
Apr 20, 2026
Merged

meszmate merged 8 commits into
mainfrom
feature/navigation-and-testing-utilities

Conversation

@meszmate

@meszmate meszmate commented Apr 20, 2026 •

Copy link
Copy Markdown
Owner

Summary

Adds five new components for navigation/layout and two testing utilities, plus a refactor consolidating duplicated fuzzy-match logic.

New components

  • StatusBar (zz.StatusBar) — single-line bar with left/center/right segment groups, each independently styled
  • Breadcrumb (zz.Breadcrumb) — horizontal path navigation with active-segment highlight and middle-ellipsis truncation when max_width is set
  • Stepper (zz.Stepper) — wizard-style progress indicator with completed/current/pending states, horizontal or vertical orientation, and keyboard navigation
  • SplitPane (zz.SplitPane) — two-pane container with a draggable divider, min-size clamping, and a compose() helper that places two pre-rendered pane strings side-by-side (or stacked) with a styled divider between them
  • CommandPalette (zz.CommandPalette) — fuzzy-filtered launcher modeled on VS Code's Ctrl-P, with prompt, placeholder, description and shortcut columns, and KeyResult (accepted / cancelled / consumed / ignored) returned from handleKey

Testing utilities (zz.testing)

  • Snapshot testing (expectSnapshot) — golden-file assertions with automatic first-run creation, ANSI-stripped normalization by default, and regeneration via ZIGZAG_UPDATE_SNAPSHOTS=1
  • Record / Replay (Recorder, Player) — captures timestamped key events to a line-based text format and parses them back, so demos and bug reports can be reproduced deterministically

Refactor

  • Fuzzy matcher extracted to src/core/fuzzy.zig (exposed as zz.fuzzy). Previously duplicated inline in list.zig and dropdown.zig. Adds matchPositions for highlighting matched characters and a rank helper for sorted results.

Test plan

  • zig build passes with no warnings
  • zig build test — 400+ tests pass, including new tests for every added module
  • Manually exercise StatusBar, Breadcrumb, Stepper, SplitPane, CommandPalette in a terminal (showcase integration in a follow-up)
  • Verify ZIGZAG_UPDATE_SNAPSHOTS=1 regenerates snapshots on a real component
  • Record a short session with Recorder, replay it through Player, confirm key-by-key equivalence

Consolidate the fuzzy scoring logic previously duplicated inline in list
and dropdown components into src/core/fuzzy.zig. Adds matchPositions for
highlighting and a rank helper, exposed via zz.fuzzy.
Single-line bar with left/center/right segment groups, each with
independent styling. Useful as a footer for editor-style apps and
dashboards. Exposed via zz.StatusBar.
Horizontal path navigation with styled segments, custom separator, and
middle-ellipsis truncation when max_width is set. Highlights the final
segment as the active location. Exposed via zz.Breadcrumb.
Multi-step progress indicator with completed/current/pending states,
horizontal or vertical orientation, and keyboard navigation. Useful for
wizard-style flows. Exposed via zz.Stepper.
Two-pane container with orientation, draggable divider (via growA/growB
or arrow keys), min-size clamping, and string composition helper. Caller
renders each pane using the sizes returned by dims(). Exposed via
zz.SplitPane.
Fuzzy-filtered command launcher with prompt, placeholder, description
and shortcut columns, arrow-key navigation, and escape/enter semantics
returned via KeyResult. Pairs with the new fuzzy matcher utility.
expectSnapshot compares rendered output against a golden file and writes
the snapshot when missing. ANSI-aware: by default strips escape codes and
trailing whitespace for stable goldens. Set ZIGZAG_UPDATE_SNAPSHOTS=1
to regenerate existing snapshots. Exposed via zz.testing.
Recorder captures timestamped key events to a line-based text format;
Player parses them back for deterministic replay of demos and bug
reports. Supports modifiers, character codepoints, and escaped paste
strings. Exposed via zz.testing.Recorder and zz.testing.Player.
@meszmate
meszmate merged commit c0414e2 into main Apr 20, 2026
9 checks passed
@meszmate
meszmate deleted the feature/navigation-and-testing-utilities branch April 24, 2026 13:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant